package com.samtech.primefaces.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.samtech.domain.EtAirport;
import com.samtech.primefaces.dao.EtAirportDao;
import com.samtech.primefaces.service.EtAirportService;

@Service("etAirportService")
public class EtAirportServiceImpl implements EtAirportService{

	private EtAirportDao etAirportDAO;
	
	
	public EtAirportServiceImpl( ) {
	
	}
	
	@Autowired
	public void setEtAirportDAO( @Qualifier("etAirportDao") EtAirportDao etAirportDAO) {
		this.etAirportDAO = etAirportDAO;
	}
	
	@Transactional
	public void createNew(EtAirport et) {
		etAirportDAO.persist(et);
	}

	@Transactional(readOnly=true)
	public List<EtAirport> findAll() {
		return etAirportDAO.loadAll();//
	}

	

	@Transactional
	public void update(EtAirport et) {
		etAirportDAO.update(et);
	}
	
	@Transactional
	public void remove(EtAirport et) {
		etAirportDAO.delete(et);
	}

	@Transactional(readOnly=true)
	public EtAirport findById(String airportCode) {
		return etAirportDAO.loadById(airportCode);
	}
	@Transactional
	public void batchCreate(EtAirport[] ets) {
		if(ets==null)return;
		if(ets.length<1)return;
		for(int i=0;i<ets.length;i++)
		etAirportDAO.persist(ets[i]);
	}
}